const express = require("express");
const router = express.Router();
const deviceManage = require("../router_handler/deviceManage");

// 导入解析 formdata 格式表单数据的包
const multer = require('multer')
// 导入处理路径的核心模块
const path = require('path')
// 创建 multer 的实例对象，通过 dest 属性指定文件的存放路径
const upload = multer({
    dest: path.join(__dirname, '../uploads')
})


//----------------------------------------------------------------
// 获取所有信息路由
router.get('/deviceManage/deviceList/', deviceManage.deviceList);
// 添加信息路由
router.post('/deviceManage/addDevice/', upload.single('device_picture'), deviceManage.addDevice);
// 获取分类和实验室信息路由
router.get('/deviceManage/getcateAddLab/', deviceManage.getcateAddLab);
// 根据性别获取楼栋
router.get('/deviceManage/getLou/:sex', deviceManage.getLou);
// 根据id获取信息路由
router.get('/deviceManage/deviceList/:id', deviceManage.getDevice);
// 根据id修改信息路由
router.post('/deviceManage/editDevice/', upload.single('device_pic'), deviceManage.editDevice);
// 根据id审核路由
router.get('/deviceManage/auditDevice/:id', deviceManage.auditDevice);
// 根据id维修路由
router.get('/deviceManage/repairDevice/', deviceManage.repairDevice);
// 根据id恢复使用路由
router.get('/deviceManage/recoverDevice/:id', deviceManage.recoverDevice);
// 根据id报废路由
router.get('/deviceManage/deleteDevice/:id', deviceManage.deleteDevice);
// 获取所有报废信息路由
router.get('/deviceManage/deleteDeviceList/', deviceManage.deleteDeviceList);
// 获取所有维修信息路由
router.get('/deviceManage/repairDeviceList/', deviceManage.repairDeviceList);
// 根据id借用路由
router.get('/deviceManage/applyDevice/:id', deviceManage.applyDevice);
// 根据id审核借用路由
router.get('/deviceManage/auditApplyDevice/:id', deviceManage.auditApplyDevice);
// 根据id归还借用路由
router.get('/deviceManage/returnDevice/:id', deviceManage.returnDevice);
// 获取所有借用日志路由
router.get('/deviceManage/borrowDeviceLog/', deviceManage.borrowDeviceLog);
// 根据id查看图片路由
router.get('/deviceManage/viewDevice/:id', deviceManage.viewDevice);
// 根据id查看图片路由-借用日志表
router.get('/deviceManage/viewBorrowDeviceLog/:id', deviceManage.viewBorrowDeviceLog);
// 根据id查看图片路由-报修日志表
router.get('/deviceManage/viewRepairDeviceLog/:id', deviceManage.viewRepairDeviceLog);

//----------------------------------------------------------------
module.exports = router